#ifndef MYQGRAPHICSVIEW_H
#define MYQGRAPHICSVIEW_H
#include <QKeyEvent>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QMouseEvent>
#include <QScrollBar>
#include <QPen>
#include <vector>
#include "interestNode.h"

using namespace std;

class MyQGraphicsView: public QGraphicsView
{
private:
    QPointF GetMeanPos(std::vector<QPointF> data);//获取一组点中间位置

protected:
    void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
    void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
    //Q_DECL_OVERRIDE用于声明一个函数是覆盖了基类中的同名函数。
    //当你在派生类中重写基类的函数时，使用 Q_DECL_OVERRIDE 宏可以确保函数的签名与基类中定义的函数签名完全匹配，
    //这样当派生类的对象使用基类的接口时，派生类的函数会被调用。
private:
    double m_scalnum;        //缩放系数
    QPointF m_startpos;     //鼠标开始点
    QPointF m_endpos;         //鼠标结束点
    QPointF nowPoi;             //鼠标右键记录下来的坐标
    QPointF lineStart;          //作图线段的始末点
    QPointF lineEnd;
    vector<QPointF> interest;   //存储景点坐标
    double m_posx;           //视图移动参数x
    double m_posy;             //试图移动参数y


public:
    MyQGraphicsView(QWidget *parent = 0);
    void drawPoint(const QPointF &point);   //绘制一个点
    void initMap();
    void drawLine(const QPointF &point1,const QPointF &point2);
    QPointF getPoi();
    void setLine(double x1,double y1,double x2,double y2);
    void setInterest(vector<QPointF> data);
    void drawInterest();

};

#endif // MYQGRAPHICSVIEW_H
